/**
 * Created by hsia on 2017/4/12.
 */
var tempChargeTab = function(targetObj){
    this.sysUtils = new kendoUtils();
    this.targetObj = targetObj;
    this.init();
    return this;
};
tempChargeTab.prototype={
    init:function(){
        var bindFieldArray = this.sysUtils.getBindFieldArray(this.targetObj);
        var bindFunctionArray = [
            {fName:"loadPage",fs:this.loadPage}];
        this.bindBaseModels = new bindBaseModel(null,bindFieldArray,bindFunctionArray,null);
        this.sysUtils.bindDoucment(this.bindBaseModels,this.targetObj,this);
        this.initTab();
    },
    initTab:function () {
        var that = this;
        var result = tempchargeList.editResult;
        if(result){
            var typeName = result.chargeParamCode;
            that.targetObj.find("#"+typeName).parent("li").show();
            that.targetObj.find("#"+typeName).parent("li").addClass('select');
            that.targetObj.find("#"+typeName).parent("li").siblings().each(function(){
                $(this).removeClass('select');
                $(this).hide();
            });
            that.targetObj.find("#ConentDiv").load('views/parkLotCenter/chargeStandard/'+typeName+'Charge_Edit.html');
            that.showImg(typeName);
        }else{
            that.targetObj.find("#ConentDiv").load('views/parkLotCenter/chargeStandard/unitTimeCharge_Edit.html');
            that.showImg("unitTime");
        }
    },
    loadPage:function (e) {
        var that = this;
        var name ='';
        if(isNotEmpt(e)){
            that = $(e.target).data("that");
            name = $(e.target)[0].id;
        }
        that.targetObj.find('ul li').each(function () {
            if(name == this.children[0].id){
                $(this).addClass("select");
            }else{
                $(this).removeClass("select");
            }
        });
        that.targetObj.find("#ConentDiv").load('views/parkLotCenter/chargeStandard/'+name+'Charge_Edit.html');
        that.showImg(name);
    },
    showImg:function(typeName){
    	var img = $("<img></img>");
        img.attr("src","views/parkLotCenter/chargeStandard/images/" + typeName + ".png");
        this.targetObj.find(".icon-rule").empty().append(img);
    }
}